package com.xunheyun.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import ch.ethz.ssh2.Session;
import ch.ethz.ssh2.StreamGobbler;

public class ConsoleUtils {

	public static StringBuffer console = new StringBuffer();
	private static BufferedReader br;

	public static void console(Session session) throws IOException {

		InputStream stdout = new StreamGobbler(session.getStdout());
		br = new BufferedReader(new InputStreamReader(stdout));

		while (true) {
			String line = br.readLine();
			if (line == null)
				break;
			console.append(line);
			System.out.println(line);
		}
	}
}
